<input value="testip" type="button" onclick="checkip()"/>
<div id="ip_agent"></div>
<textarea id="text_clipboard" ></textarea>

<script type="text/javascript">
function validateIP(str){
    return !!str.match(/^((25[0-5]|2[0-4]\d|[01]?\d\d?)($|(?!\.$)\.)){4}$/);
}
function checkip(){
    var vm_ip=document.getElementById("text_clipboard").value.trim();
    console.log(vm_ip);
    if(validateIP(vm_ip)){
        console.log("send websocket");
    }
}
//checkip();
var abc=setInterval("checkip()",1000);
var ua = (navigator.userAgent || navigator.vendor || window.opera); 
if (ua!=null) {
    var uaName = ua.toLowerCase();
    console.log(uaName);
    if (/android/i.test(uaName)){
        console.log("android");
        document.getElementById("ip_agent").innerHTML="android";
    }else if (/ip(hone|od)/i.test(uaName)) { 
        console.log("iphone");
        document.getElementById("ip_agent").innerHTML="iphone";
    }else{
        console.log("server");
        document.getElementById("ip_agent").innerHTML="server";
    }
}
</script>

